package com.open.rbac.model.entity.sys;

import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLRestriction;

import com.open.center.jpa.model.entity.IdSpecify;
import com.open.rbac.constant.MenuType;


@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@DynamicUpdate
@SQLRestriction("is_deleted = false")
@SQLDelete(sql = "UPDATE menu SET is_deleted = 1 WHERE id = ?")
@Entity(name = "menu")
public class Menu extends IdSpecify {

    @Column(name = "parent_id", nullable = false, length = 36)
    private String parentId;

    @Column(name = "name", nullable = false, length = 64)
    private String name;

    @Column(name = "router_name", length = 64)
    private String routerName;

    @Column(name = "router_path", length = 64)
    private String routerPath;

    @Column(name = "router_component")
    private String routerComponent;

    @Column(name = "icon")
    private String icon;

    @Column(name = "method", nullable = false, length = 10)
    private String method;

    @Column(name = "url")
    private String url;

    @Convert(converter = MenuType.Converter.class)
    @Column(name = "type", nullable = false, length = 32)
    private MenuType type;

    @Column(name = "sort")
    private Integer sort;

    @Column(name = "auth_key")
    private String authKey;

    @Column(name = "enable", nullable = false)
    private Boolean enable;

    @Column(name = "remark")
    private String remark;

}
